<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>路由实例</title>
	</head>
	<body>
		<div id="app">
			<router-link to="/shopping">商场</router-link>
			<router-link to="/zoo">动物园</router-link>
			<router-view></router-view>
		</div>
		
		<template id="shopping">
			<div>
				<h3>商场组件</h3>
				<!-- 定义子路由 -->
				<router-link to="/shopping/shoe">鞋店</router-link>
				<router-link to="/shopping/huawei">华为手机店</router-link>
				<router-view></router-view>
			</div>
		</template>
		<template id="zoo">
			<div>
				<h3>动物园组件</h3>
			</div>
		</template>
		<template id="shoe">
			<div>
				<h3>鞋的组件</h3>
			</div>
		</template>
		<template id="huawei">
			<div>
				<h3>欢迎光临华为手机店</h3>
			</div>
		</template>
		
		<!--引入js函数类库  -->
		<script src="../js/vue.js"></script>
		<!-- 引入路由规则 -->
		<script src="../js/vue-router.js"></script>
		<script>
			//1.定义商场组件
			const shopping = {
				template: "#shopping"
			}
			
			const zoo = {
				template: "#zoo"
			}
			
			const shoe = {
				template: "#shoe"
			}
			
			const huawei = {
				template: "#huawei"
			}
			
			//定义路由对象
			const router = new VueRouter({
				routes:[
					{path:'/shopping', component:shopping, children:[
						{path:'/shopping/shoe', component:shoe},
						{path:'/shopping/huawei', component:huawei}
					]},
					{path:'/zoo', component:zoo}
				]
			})
			
			
			const app = new Vue({
				el: '#app',
				router
				
			})
			
		</script>
	</body>
</html>
